import Vue from 'vue'
import './plugins/axios'
import App from './App.vue'
import router from './router'
import store from './store'
import './plugins/element.js'

Vue.config.productionTip = false
router.beforeEach((to, from, next) => {
  /* 路由发生变化修改页面title */
  document.title = '极光平台'
  if (to.path.startsWith('/login')) {
    window.localStorage.removeItem('user')
    next()
  } else {
    let user = JSON.parse(window.localStorage.getItem('user'))
    console.log(user)
    if (!user) {
      next({path: '/login'})
    } else {
      next()
    }
  }
})


new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')
